﻿using Clipper.Model.DataBaseModel;
using ClipperBaseUI.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Clipper.ClipperWindow
{
    /// <summary>
    /// WinShowDateAndNum.xaml 的交互逻辑
    /// </summary>
    public partial class WinShowDateAndNum : BaseWindow
    {
        public WinShowDateAndNum()
        {
            InitializeComponent();
        }
        BLL.DataBaseBLL.StandardCurveData standardBll = new BLL.DataBaseBLL.StandardCurveData();


        StandardCurveData standard;
        private void BaseWindow_Loaded(object sender, RoutedEventArgs e)
        {
            standard = this.Tag as StandardCurveData;

            textBox.Text = standard.BatchNumber.ToString();
            textBox1.Text = standard.CloseDate.ToString();
            if (standard.IsShow == false)
            {

                button.Visibility = Visibility.Hidden;  //隐藏保存按钮
                button1.Visibility = Visibility.Hidden; //隐藏取消按钮
            }
            else if (standard.IsShow == true)
            {
                button.Visibility = Visibility.Visible;  //隐藏保存按钮
                button1.Visibility = Visibility.Visible; //隐藏取消按钮
            }

        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            //int a = 0;
            StandardCurveData model = new StandardCurveData();
            if (!textBox.Text.Trim().Equals(""))
            {
                model.BatchNumber = Convert.ToInt32(textBox.Text);
            }           
            if (!textBox1.Text.Trim().Equals(""))
            {
                model.CloseDate = DateTime.Parse(textBox1.Text);
            }
            if (textBox.Text.Trim().Equals("")||textBox1.Text.Trim().Equals(""))
            {
                WinNoticeNoEmpty empty = new WinNoticeNoEmpty();//提示不能为空
                empty.ShowDialog();
                return;
            }
            model.DetectItem = standard.DetectItem;
            bool ret = standardBll.upadateCloseDateAndNum(model);
            this.Close();
        }
    }
}
